
ALTER       proc sp_get_board_or_kit_making(@process_type varchar(50))
as
begin
declare @results Table(product_id int, Part_Number varchar (20))
 

declare bcursor cursor for 
    select product.product_id, product.part_Number from 
	product,Process_Step  where product.P_Type = 'BOARD' and p_parent_product_id = -1 and product.ProcessStep_ID in 
	(select processstep_id from Process_Step where PS_Type_Name like @process_type) 
	and product.processStep_id=Process_Step.ProcessStep_ID order by product.part_Number
declare @product_id int
declare @Part_Number varchar (20)
insert into @results values('','----BOARD------')

open bcursor
	fetch next from bcursor into @product_id, @Part_Number
	while @@fetch_status = 0
	begin
		insert into @results values(@product_id,@Part_Number)
		set @product_id = null
		set @Part_Number = null
		fetch next from bcursor into @product_id,@Part_Number
	end
close bcursor 
deallocate bcursor 

insert into @results values('','----KIT-------')
declare kcursor cursor for 
    select product.product_id, product.part_Number from product, process_step 
    where P_Type = 'KIT' and p_parent_product_id = -1 and product.ProcessStep_ID in (select processstep_id from Process_Step 
    where PS_Type_Name like @process_type) and 
    product.processStep_id=Process_Step.ProcessStep_ID order by product.part_number
open kcursor
	fetch next from kcursor into @product_id,@Part_Number
	while @@fetch_status = 0
	begin
		insert into @results values( @product_id,@Part_Number)
		set @product_id = null
		set @Part_Number = null
		fetch next from kcursor into  @product_id,@Part_Number
	end
close kcursor 
deallocate kcursor 
end

select product_id, Part_Number from @results



